package top.kpromise.ibase.base

import android.app.Activity
import android.databinding.DataBindingUtil
import android.databinding.ViewDataBinding
import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import top.kpromise.ibase.config

abstract class IBaseActivity<Bind : ViewDataBinding>: AppCompatActivity() {

    var contentView: Bind? = null
    var activity: Activity? = null

    open fun cancelCreate(): Boolean = false
    abstract fun layoutId(): Int
    open fun afterCreate(){}

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        if (cancelCreate()) {
            finish()
            return
        }
        config.lifecycleCallback?.onCreate(this)

        contentView = DataBindingUtil.setContentView(this, layoutId())
        afterCreate()
    }
}